package EXAME;

import cn.hutool.Hutool;

import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Random;

public class Test1 {
    public static void main(String[] args) throws IOException {
        //定义集合分别存男生女生
        ArrayList<String> BoyList = new ArrayList<>();
        ArrayList<String> GirlList = new ArrayList<>();

        // 统计次数
        int boyCount = 0;
        int girlCount = 0;


        //权重
        ArrayList<Integer> list = new ArrayList<>();
        Collections.addAll(list,1,1,1,1,1,1,1,0,0,0);

        //读取文件
        BufferedReader br = new BufferedReader(new FileReader("testfile\\names.txt"));
        String line;
        while ((line = br.readLine()) != null) {
            if (line.contains("男")) {
                BoyList.add(line);
            } else {
                GirlList.add(line);
            }
        }
        //随机抽取
        for (int i = 0; i < 1000000; i++) {
            Collections.shuffle(list);
            Collections.shuffle(BoyList);
            Collections.shuffle(GirlList);
            list.get(0);
            if (list.get(0) == 1) {
                String boy = BoyList.get(0);
                System.out.println(boy);
                boyCount++;
            }else {
                String girl = GirlList.get(0);
                System.out.println(girl);
                girlCount++;
            }
        }
        System.out.println("男生抽取次数为：" + boyCount);
        System.out.println("女生抽取次数为：" + girlCount);


    }
}
